/**
 * 
 */
package com.shine.icis.blo;

import java.util.Collection;
import java.util.List;

import com.shine.icis.hbean.FlowIns;
import com.shine.icis.hbean.FlowNode;
import com.shine.icis.hbean.FlowVar;
import com.shine.icis.hbean.TaskIns;

/**
 * @author zsy
 *
 */
public interface IFlowService {
	
	/**
	 * 通过流程定义ID启动流程实例
	 * @param flowDefId
	 * @return
	 */
	public FlowIns txNewFlowIns(String flowDefId, List<FlowVar> vars);
	
	/**
	 * 触发流程到一个节点
	 * @param flowInsId
	 * @param toFirst 是否转到第一节点
	 * @return
	 */
	public TaskIns txToNextNode(String flowInsId, boolean toFirst) throws Exception;
	
	/**
	 * 结束任务
	 * @param taskId
	 * @param actorId
	 * @param comment
	 * @return
	 */
	public TaskIns txEndTask(String taskId, String actorId, String comment) throws Exception;
	
	/**
	 * 强制结束流程（不触发结束事件）
	 * @param flowInsId
	 */
	public FlowIns txForceEndFlowIns(String flowInsId);
	
	/**
	 * 查找待办任务
	 * @param userId
	 * @param roleIds
	 * @return
	 */
	public List<TaskIns> getTasks(String userId, List<String> roleIds);
	
	/**
	 * 取得已结束的任务
	 * @param flowInsId
	 * @return
	 */
	public List<TaskIns> getEndTasks(String flowInsId);
	
	
	
	/**
	 * 是否第一个步骤的任务
	 * @param taskId
	 * @return
	 */
	public boolean csFirstNode(String taskId);
	
	/**
	 * 新增步骤
	 * @param flowId
	 * @param nodeName
	 * @param actionHandler
	 * @param assignUsers
	 */
	public void addFlowNode(String flowId, String nodeName, String actionHandler, String[] assignUsers);
	
	/**
	 * 修改步骤
	 * @param nodeId
	 * @param nodeName
	 * @param actionHandler
	 * @param assignUsers
	 */
	public void modifyFlowNode(String nodeId, String nodeName, String actionHandler, String[] assignUsers);
	
	/**
	 * 删除步骤
	 * @param nodeId
	 */
	public void deleteFlowNode(String nodeId);
	
	/**
	 * 查询所有步骤
	 * @param flowId
	 * @return
	 */
	public Collection<FlowNode> getFlowNodes(String flowId);
	
	/**
	 * 排序
	 * @param nodeId
	 * @param toUp
	 */
	public void txSortFlowNode(String nodeId, boolean sortUp);
	
}
